package com.web.dao;

import com.web.entity.MskSaleOrder;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class MskSaleOrderSqlProvider {


    public String insertSelective(MskSaleOrder record) {
        BEGIN();
        INSERT_INTO("t_msk_sale_order");

        if (record.getmId() != null) {
            VALUES("m_id", "#{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }

        if (record.getNum() != null) {
            VALUES("num", "#{num,jdbcType=INTEGER}");
        }

        if (record.getDealTime() != null) {
            VALUES("deal_time", "#{dealTime,jdbcType=TIMESTAMP}");
        }

        if (record.getDealPrice() != null) {
            VALUES("deal_price", "#{dealPrice,jdbcType=DECIMAL}");
        }

        if (record.getDealAmt() != null) {
            VALUES("deal_amt", "#{dealAmt,jdbcType=DECIMAL}");
        }

        if (record.getPoundageRate() != null) {
            VALUES("poundage_rate", "#{poundageRate,jdbcType=DOUBLE}");
        }

        if (record.getPoundage() != null) {
            VALUES("poundage", "#{poundage,jdbcType=DECIMAL}");
        }

        if (record.getStatus() != null) {
            VALUES("status", "#{status,jdbcType=INTEGER}");
        }

        if (record.getIsFirst() != null) {
            VALUES("is_first", "#{isFirst,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }


    public String updateByPrimaryKeySelective(MskSaleOrder record) {
        BEGIN();
        UPDATE("t_msk_sale_order");

        if (record.getmId() != null) {
            SET("m_id = #{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }

        if (record.getNum() != null) {
            SET("num = #{num,jdbcType=INTEGER}");
        }

        if (record.getDealTime() != null) {
            SET("deal_time = #{dealTime,jdbcType=TIMESTAMP}");
        }

        if (record.getDealPrice() != null) {
            SET("deal_price = #{dealPrice,jdbcType=DECIMAL}");
        }

        if (record.getDealAmt() != null) {
            SET("deal_amt = #{dealAmt,jdbcType=DECIMAL}");
        }

        if (record.getPoundageRate() != null) {
            SET("poundage_rate = #{poundageRate,jdbcType=DOUBLE}");
        }

        if (record.getPoundage() != null) {
            SET("poundage = #{poundage,jdbcType=DECIMAL}");
        }

        if (record.getStatus() != null) {
            SET("status = #{status,jdbcType=INTEGER}");
        }

        if (record.getIsFirst() != null) {
            SET("is_first = #{isFirst,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }


}